package com.codef.sharp.user.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codef.sharp.common.database.utils.PageUtil;
import com.codef.sharp.user.dao.UserDao;
import com.codef.sharp.user.entity.UserEntity;
import com.codef.sharp.user.service.UserService;
import com.codef.sharp.user.vo.UserQueryVo;
import org.springframework.stereotype.Service;

/**
 * @author zhanrf
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

    @Override
    public Page<UserEntity> getByPage(UserQueryVo queryVo) {
        Page<UserEntity> page = PageUtil.getPage();
        return this.lambdaQuery()
                .like(StrUtil.isNotBlank(queryVo.getUsername()), UserEntity::getUsername, queryVo.getUsername())
                .like(StrUtil.isNotBlank(queryVo.getPhoneNumber()), UserEntity::getPhoneNumber, queryVo.getPhoneNumber())
                .page(page);
    }
}